<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <form action="">
            <P>
                <label>手机号码：</label>
                <input type="text" name="userName" type="text" id="userName" onblur="CheckTel()"><span
                    id="inf_tel"></span>
            </P>
            <P>
                <label>密码：</label>
                <input type="password" name="pwd" type="text" id="pwd" onblur="checkPwd()"><span id="inf_pwd"></span>
            </P>
            <P>
                <label>昵称：</label>
                <input type="text" name="nickname" type="text" id="nickname" onblur="nickname()">
            </P>
            <P>
                <label>邮箱：</label>
                <input type="email" name="email" type="text" id="email" onblur="checkEmail()">
            </P>
            <input type="button" value="注册" id="tj">
        </form>
    </div>

    <script src="../JS/jquery-3.4.1.min.js"></script>
    <script>

        // 注册验证
        function check() {
            if (checkEmail() && checkPwd() && nickname() && CheckTel()) {
                return true;
            }
            return false;
        }
        // 手机号码验证 
        function CheckTel() {
            var reg = /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;
            var telVal = $("#userName").val();
            if (reg.test(telVal)) {
                //符合
                $('#inf_tel').html("√")
                return true;
            }
            else if (telVal == "") {
                $('#inf_tel').html("手机号不能为空")
                return false;
            }
            else {
                $('#inf_tel').html("手机格式不正确，请重新输入")
                return false;
            }
        };
        //密码验证
        function checkPwd() {
            var pwd = $("#pwd").val();
            var obj = $("#inf_pwd");
            obj.html("");
            if (pwd == "") {
                //使用innerHTML属性设置span标签中的内容
                obj.html("密码不能为空");
                return false;
            }
            obj.html("√");
            return true;
        }
    </script>
</body>

</html>